package com.sky.config;

import com.sky.properties.QiNiuOssProperties;
import com.sky.utils.QiNiuOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJndi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class OSSConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public QiNiuOssUtil qiNiuOssUtil(QiNiuOssProperties qiNiuOssProperties){
        QiNiuOssUtil qiNiuOssUtil = new QiNiuOssUtil(
                qiNiuOssProperties.getEndpoint(),
                qiNiuOssProperties.getAccessKeyId(),
                qiNiuOssProperties.getAccessKeySecret(),
                qiNiuOssProperties.getBucketName()
        );
//        System.out.println(qiNiuOssUtil.toString());
        return qiNiuOssUtil;


    }

}
